package com.kws.commercial.controller;

import com.github.pagehelper.PageInfo;
import com.kws.commercial.dao.CommercialProjectQuotationManagement;
import com.kws.commercial.dao.Info.QueryFileManagementInfo;
import com.kws.commercial.dao.Rq.CreateFileManagementRq;
import com.kws.commercial.dao.Rq.QueryFileManagementPageRq;
import com.kws.commercial.service.CommercialFileManagementService;
import com.kws.commercial.service.CommercialProjectQuotationService;
import com.kws.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <b>CommercialFileManagementController</b>
 *
 * @description: CommercialFileManagementController <br>
 * @date: 2024/10/29 10:35 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "项目资料管理模块")
@RestController
public class CommercialFileManagementController {
   private static final Logger logger = LoggerFactory.getLogger(CommercialFileManagementController.class);

   @Autowired
    private CommercialFileManagementService commercialFileManagementService;

   @Autowired
   private CommercialProjectQuotationService commercialProjectQuotationService;

   @ApiOperation("查询所有项目名称列表")
   @GetMapping("/query/schemeLst")
   public R<List<CommercialProjectQuotationManagement>> querySchemeList(){
       List<CommercialProjectQuotationManagement> resultList = commercialProjectQuotationService.querySchemeList();
       return R.ok(resultList);
   }


    @ApiOperation("分页查询项目资料列表")
    @GetMapping("/query/fileManagement/page")
    public R<PageInfo<QueryFileManagementInfo>> queryFileManagementPage(@RequestBody QueryFileManagementPageRq rq){
        PageInfo<QueryFileManagementInfo> pageInfo = commercialFileManagementService.queryFileManagementPage(rq);
        return R.ok(pageInfo);
    }

    @ApiOperation("创建项目文件资料")
    @PostMapping("/create/fileManagement")
    public R createFileManagement(@RequestBody CreateFileManagementRq rq){
        boolean status = commercialFileManagementService.createFileManagement(rq);
        return R.ok(status);
    }

    @ApiOperation("根据文件ID查询文件信息")
    @GetMapping("/query/fileManagement/byId")
    public R<QueryFileManagementInfo> queryFileManagementById(@RequestParam Long id){
        QueryFileManagementInfo info = commercialFileManagementService.queryFileManagementById(id);
        return R.ok(info);
    }


    @ApiOperation("根据文件ID删除文件信息")
    @GetMapping("/delete/fileManagement/byId")
    public R deleteFileManagementById(@RequestParam Long id){
        boolean status = commercialFileManagementService.deleteFileManagementById(id);
        return R.ok(status);
    }
}
